package com.shengqi.xinnongren.work.ui.home.presenter;

import com.shengqi.xinnongren.common.base.BasePresenter;
import com.shengqi.xinnongren.common.config.network.Constants;
import com.shengqi.xinnongren.common.config.network.RetrofitHelper;
import com.shengqi.xinnongren.common.config.user.UserManager;
import com.shengqi.xinnongren.work.model.HttpRespond;
import com.shengqi.xinnongren.work.ui.home.model.TakeGoodsBean;
import com.shengqi.xinnongren.work.ui.home.view.TakeGoodsView;

import org.json.JSONObject;

import io.reactivex.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.RequestBody;

public class TakeGoodsPresenter extends BasePresenter<TakeGoodsView> {

    public void getGoodsInfo() {
        JSONObject jsonData = Constants.getJsonData(null, UserManager.getInstance().getToken());
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonData.toString());
        addTask(RetrofitHelper.getInstance().getService().getTakeGoodsInfo(requestBody), new Consumer<HttpRespond<TakeGoodsBean>>() {
            @Override
            public void accept(HttpRespond<TakeGoodsBean> takeGoodsBeanHttpRespond) {
                getView().getGoodsInfoRes(takeGoodsBeanHttpRespond);
            }
        });
    }
}
